<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('qr_codes', function (Blueprint $table) {
            $table->id();
            $table->foreignId('car_owner_id')->constrained()->onDelete('cascade')->comment('车主ID');
            $table->text('data')->nullable()->comment('二维码内容数据');
            $table->string('url', 255)->nullable()->comment('二维码URL');
            $table->string('path', 255)->nullable()->comment('二维码存储路径');
            $table->boolean('is_active')->default(true)->comment('是否激活');
            $table->timestamps();
            
            $table->index('car_owner_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('qr_codes');
    }
}; 